﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ylh.Data;
using Ylh.ElvModel;
using Ylh.Enums;
using System.Data;

namespace Ylh.ElvBLL
{
    class CustMettingElvBLL
    {
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool InsertMettingInfo(string ConStr, Ylh.ElvModel.TbCustMetting model)
        {
            return TbCustMetting.InserObjedct(model, ConStr);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateMettingInfo(string ConStr, Ylh.ElvModel.TbCustMetting model)
        {
            return TbCustMetting.Update(model, ConStr);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string ConStr, String CustMettingID)
        {
            TbCustMetting met = new TbCustMetting();
            OQLWhere where = new OQLWhere(met);
            where.AND(met.CustMettingID, OperateType.等于, CustMettingID);
            return TbCustMetting.Delete(where, ConStr);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Ylh.ElvModel.TbCustMetting GetModel(string ConStr, String CustMettingID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCustMetting() { CustMettingID = CustMettingID };
            DataTable dt = TbCustMetting.Select(where, ConStr);
            List<TbCustMetting> li = Ylh.Pub.ConverDt2Model.DtToList<TbCustMetting>(dt);
            if (dt.Rows.Count == 0 || li.Count == 0) return new TbCustMetting();
            return li[0];
        }

        public DataTable GetMettingInfo(string ConStr, string StaffID, string CustID)
        {
            SqlWhere where = new SqlWhere();
            TbCustMetting Cmet = new TbCustMetting();
            where.Info = new TbCustMetting() { StaffID = StaffID, CustID = CustID };
            return TbCustMetting.Select(where, ConStr);
        }


        public bool GetCountmetting(string ConStr, string StaffID, string CustID)
        {
            SqlWhere where = new SqlWhere();
            TbCustMetting Cmet = new TbCustMetting();
            where.Info = new TbCustMetting() { StaffID = StaffID, CustID = CustID };

            return TbCustMetting.Select(where, ConStr).Rows.Count > 0;
        }


    }
}
